/**
 * 
 */
package co.fitstart.payment.entity.transaction;

/**
 * @author mohanlan
 * @author lute
 *
 */
public enum OperationType {

    /** 创建支付记录 */
    CREATE(0, "create"),
    
    /** 支付 */
    PAY(1, "pay"),
    
    /** 退款 */
    REFUND(2, "refund"),
    
    /** 支付平台回调 */
    PAYMENT_CALLBACK(3, "payment-callback");
    
    private int code;
    
    private String alias;
    
    /**
     * @param code
     * @param alias
     */
    private OperationType(int code, String alias) {
        this.code = code;
        this.alias = alias;
    }
    
    /**
     * @return the code
     */
    public int getCode() {
        return code;
    }
    
    /**
     * @return the alias
     */
    public String getAlias() {
        return alias;
    }
    
    /**
     * Get transaction record operate type according to code
     * 
     * @param code
     * @return
     */
    public static OperationType codeOf(int code) {
        for(OperationType status : OperationType.values()) {
            if(status.getCode() == code) {
                return status;
            }
        }
        return null;
    }

}
